﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace GLYFrom.TCGL
{
    public partial class CP_insert : Form
    {
        public CP_insert()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            string Name = this.text_Name.Text.Trim();
            string Class = this.combo_Class.Text.Trim();
            string JiaGe = this.text_JiaGe.Text.Trim();
            string JieShao = this.text_JieShao.Text.Trim();
            if (Name.Length > 0 && Class.Length > 0 && JiaGe.Length > 0 && JieShao.Length>0)
            {
                int sr = DBHelper.ZSG(string.Format("insert into T_CaiPin values('{0}','{1}','{2}','{3}')", Name, Class, JiaGe,JieShao));
                if (sr > 0)
                {
                    MessageBox.Show("添加成功！");
                }
                else
                {
                    MessageBox.Show("添加失败！");
                }
            }
            else
            {
                MessageBox.Show("添加失败,请填写完整！");
                return;
            }
            
        }

        private void TC_insert_Load(object sender, EventArgs e)
        {
            DataTable table = DBHelper.select("select DISTINCT Class from T_CaiPin");
            this.combo_Class.DisplayMember ="Class";
            this.combo_Class.DataSource = table;
        }
    }
}
